package demon1;

import javax.swing.*;
import java.io.*;
import java.util.Scanner;

public class excel{
    public static void main(String[] args)  {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入要复制的文件路径");
        String srcPath=scanner.next();
        System.out.println("请输入被复制的文件路径:");
        String destrPath=scanner.next();
        File srcfile=new File(srcPath);
        if(!srcfile.isFile()){
            System.out.println("src非法");
            return;
        }
        File destFile=new File(destrPath);
        if(!destFile.getParentFile().isDirectory()){
            System.out.println("dest非法");
            return;
        }
        try(InputStream inputStream=new FileInputStream(srcfile);
        OutputStream outputStream=new FileOutputStream(destFile)){
            while(true){
                byte[]bytes=new byte[4096];
                int n=inputStream.read(bytes);
                System.out.println(n);
                if(n==-1){
                    break;
                }
                outputStream.write(bytes,0,n);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
